import json
from air_history.settings import logger

class AirHistoryPipeline(object):
    def open_spider(self, spider):
        logger.info('open_spider myprint pipelines.py 第四步')
        self.file = open('area.json', 'w')

    def process_item(self, item, spider):
        logger.info('process_item myprint pipelines.py 第六步')
        context = json.dumps(dict(item),ensure_ascii=False) + '\n'
        self.file.write(context)
        return item

    def close_spider(self,spider):
        logger.info('close_spider myprint pipelines.py 第七步')
        self.file.close()